Various techniques have evolved for improving the performance of computer software. A category of techniques commonly called “optimization” evaluates a piece of software and modifies its operation to improve performance while preserving the software's functionality.
For example, the architecture of many computer systems organizes memory into pages. Such systems may include a mechanism by which a limited number of pages can be loaded into primary memory for access by a processor. Additional pages can be stored in secondary memory; however, when the system accesses secondary memory, processing is suspended while moving the pages from secondary memory to primary memory.
For purposes of illustration, consider a piece of software having instructions for four procedures A, B, C, and D executing in sequence in a system having only one page of primary memory. If procedures A and C are on a first page, and procedures B and D are on a second page, the following eight actions take place when the piece of software is executed:
1. Move first page to primary memory
2. Execute procedure A
3. Move second page to primary memory
4. Execute procedure B
5. Move first page to primary memory
6. Execute procedure C
7. Move second page to primary memory
8. Execute procedure D.
One optimization technique places code portions which execute within a certain period of time in close proximity to each other. Thus, A and B are placed close to each other (e.g., on the same page) and C and D are place close to each other. Applying such optimization to the above piece of software, the following six actions take place when the piece of software is executed:
1. Move first page to primary memory
2. Execute procedure A
3. Execute procedure B
4. Move first page to primary memory
5. Execute procedure C
6. Execute procedure D.
Thus, optimization of the software has saved two actions. Since moving pages into primary memory typically requires a large amount of time in terms of processing cycles, the savings is significant. This optimization technique can be applied to large software projects to provide dramatic savings in processing resources.
Although manual optimization is possible, software developers employ a technique called profiling to automate the process. Profiling observes software's behavior during execution to assist in optimization. For example, information about which procedures are executed within a certain period of time can be collected for the above-described optimization technique.